// pages/movies/movie-detail/movie-detail.js
import { Movie } from 'class/Movie.js';
const app = getApp();
Page({

  data: {
    movie: {}
  },
  // 使用ES6编写代码 module、class、promise、=>
  onLoad: function (options) {
    var movieId = options.id;
    var url = app.globalData.doubanBase + "/v2/movie/subject/" + movieId;
    var movie = new Movie(url);
    var that = this;
    // movie.getMovieData(function (movie) {
    //   that.setData({
    //     movie: movie
    //   })
    // })
    // 箭头函数，这里的this，为定义箭头函数的上下文环境
    movie.getMovieData((movie) => {
      this.setData({
        movie: movie
      })
    })

  },
  viewMoviePostImg: function (event) {
    var src = event.currentTarget.dataset.src;
    wx.previewImage({
      urls: [src],
      current: src
    })
  }
})